from django.db import models

# Create your models here.
from django.utils import timezone 

class Post(models.Model):           #定义我们的模型 一个post对象
	author = models.ForeignKey('auth.User')
	title = models.CharField(max_length=200)
	text = models.TextField()
	create_date = models.DateTimeField(default=timezone.now)
	publish_date = models.DateTimeField(blank=True,null=True)

	def publish(self):     #定义publish的方法
		self.publish_date = timezone.now()
		self.save()

	def __str__ (self):
		return self.title   #调用 __str__() 得到文章标题的文本

